namespace NExt.UI.Base.Data.Controller
{
    public abstract class AbstractDataControllerScript : IDataControllerScript
    {
        private readonly string textt;

        protected AbstractDataControllerScript(string bodyTextFormat, string externalFunctionName, params string[] parameterNames)
        {
            string parameterString = BuildParameterString(parameterNames);
            textt = string.Format(bodyTextFormat, externalFunctionName, parameterString);
        }

        public string text
        {
            get { return textt; }
        }

        private string BuildParameterString(string[] parameterNames)
        {
            if (parameterNames == null || parameterNames.Length == 0)
            {
                return string.Empty;
            }

            string parameterString = string.Join(",", parameterNames);
            return parameterString;
        }
    }
}